﻿using CUREBusinessLogicLayer.Harmful;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
/*************************************************************************************

     liudan  add  12.11  添加技术判定书
  
*************************************************************************************/
namespace CURE.Harmful
{
    public partial class TBookAdd : System.Web.UI.Page
    {
        private string action; public string Action { get { return action; } set { action = value; } }//类型 add新增  edit编辑
        
        #region 变量

        public string id; public string Id { get { return id; } set { id = value; } }//编号（主键）
        public string hid; public string HID { get { return hid; } set { hid = value; } }//F卡信息ID
        public string fid; public string FID { get { return fid; } set { fid = value; } }//F卡号
        public string saccepter; public string Saccepter { get { return saccepter; } set { saccepter = value; } }//受领担当
        public string acceptDate; public string AcceptDate { get { return acceptDate; } set { acceptDate = value; } }//受领日

        public string stage; public string Stage { get { return stage; } set { stage = value; } }//期别
        public string model; public string Model { get { return model; } set { model = value; } }//型号
        public string category; public string Category { get { return category; } set { category = value; } }//类别
        public string fdate; public string Fdate { get { return fdate; } set { fdate = value; } }//F卡时间
        public string amount; public string Amount { get { return amount; } set { amount = value; } }//数量（BT或包）

        public string jaccepter; public string Jaccepter { get { return jaccepter; } set { jaccepter = value; } }//技术课判定担当
        public string sdate; public string Sdate { get { return sdate; } set { sdate = value; } }//判定担当受领日期
        public string method; public string Method { get { return method; } set { method = value; } }//处理方法
        public string mdate; public string MDate { get { return mdate; } set { mdate = value; } }//再处理日限
        public string pddate; public string PDDate { get { return pddate; } set { pddate = value; } }//判定日

        public string jcdate; public string JCDate { get { return jcdate; } set { jcdate = value; } }//决裁日期
        public string fhdate; public string FHDate { get { return fhdate; } set { fhdate = value; } }//返回申请部门日期
        public string pdsdate; public string PDSDate { get { return pdsdate; } set { pdsdate = value; } }//判定书处理完成返回
        public string backDate; public string BackDate { get { return backDate; } set { backDate = value; } }//返回日期
        public string result; public string Result { get { return result; } set { result = value; } }//判定结果

        public string remarks; public string Remarks { get { return remarks; } set { remarks = value; } }//备注
        public string recorder; public string Recorder { get { return recorder; } set { recorder = value; } }//录入人
        public string recordDate; public string RecordDate { get { return recordDate; } set { recordDate = value; } }//录入时间
        private string page;

        public string Page1
        {
            get { return page; }
            set { page = value; }
        }
               
        #endregion

        private TBookBll tbookbll = new TBookBll();

        protected void Page_Load(object sender, EventArgs e)
        {
            hid = Request.QueryString["HID"];
            fid = Request.QueryString["FID"];
            Page1 = Request.QueryString["PAGE"];
            action = tbookbll.GetAction(hid,out id);
            if (action == "editTBook")
            {
                DataTable dt = new DataTable();
                dt = tbookbll.GetBook(id);

                #region 赋值
                id = ColumnChange(dt, "ID");//编号（主键）
                saccepter = ColumnChange(dt, "Saccepter");//受领担当
                acceptDate = ColumnChange(dt, "AcceptDate");//受领日

                stage = ColumnChange(dt, "Stage");//期别
                model = ColumnChange(dt, "Model");//型号
                category = ColumnChange(dt, "Category");//类别
                fdate = ColumnChange(dt, "Fdate");//F卡时间
                amount = ColumnChange(dt, "Amount");//数量（BT或包）

                jaccepter = ColumnChange(dt, "Jaccepter");//技术课判定担当
                sdate = ColumnChange(dt, "Sdate");//判定担当受领日期
                method = ColumnChange(dt, "Method");//处理方法
                mdate = ColumnChange(dt, "MDate");//再处理日限
                pddate = ColumnChange(dt, "PDDate");//判定日

                jcdate = ColumnChange(dt, "JCDate");//决裁日期
                fhdate = ColumnChange(dt, "FHDate");//返回申请部门日期
                pdsdate = ColumnChange(dt, "PDSDate");//判定书处理完成返回
                backDate = ColumnChange(dt, "BackDate");//返回日期
                result = ColumnChange(dt, "Result");//判定结果
                if (result == "" || result == null) { result = "NG"; }

                remarks = ColumnChange(dt, "Remarks");//备注
                recorder = ColumnChange(dt, "Recorder");//录入人
                recordDate = ColumnChange(dt, "RecordDate");//录入时间
                #endregion
            }
            else 
            {
                result = "NG";
                //新增
                if (HttpContext.Current.Request.Cookies["MWS_User"] != null)
                {
                    recorder = HttpContext.Current.Request.Cookies["MWS_User"]["NAME"];
                    //HttpContext.Current.Request.Cookies["MWS_User"]["ID"];
                }
                recordDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                id = tbookbll.GetID();
            }
        }

        /// <summary>
        /// 获取datatable对应列的数据
        /// </summary>
        /// <param name="columnname"></param>
        /// <returns></returns>
        private string ColumnChange(DataTable dt,string columnname)
        {
            return dt.Rows[0][columnname].ToString();
        }

        /// <summary>
        /// 根据id获取对应台账明细
        /// </summary>
        /// <returns></returns>
        private DataTable GetLedgerByFid()
        {
            DataTable dt = new DataTable();
           
            return dt;
        }


    }
}